# Maintainer: User0 <user0thenyancat@proton.me>
# Reference: <https://postmarketos.org/vendorkernel>
# Kernel config extracted from: https://androidfilehost.com/?fid=24052804347795607

pkgname=linux-samsung-loganrelte
pkgver=3.4.113
pkgrel=1
pkgdesc="Samsung Galaxy Ace 3 LTE kernel fork"
arch="armv7"
_carch="arm"
_flavor="samsung-loganrelte"
url="https://kernel.org"
license="GPL-2.0-only"
options="!strip !check !tracedeps pmb:cross-native"
makedepends="
	bash
	bc
	devicepkg-dev
	elfutils-dev
	gcc6
	gmp-dev
	installkernel
	linux-headers
	perl
	sed
	xz
"

# Source
_repository="android_kernel_samsung_msm8930-common"
_commit="0a35d79cc544b24168450e46216dd649c7fd339b"
_config="config-$_flavor.$arch"
source="
	$pkgname-$_commit.tar.gz::https://github.com/MSM8930-Samsung/$_repository/archive/$_commit.tar.gz
	$_config
	01_msm-fix-perf_trace_counters.patch
	02_gpu-msm-fix-gcc5-compile.patch
	03_fix-video-argb-setting.patch
	linux3.4-ARM-8933-1-replace-Sun-Solaris-style-flag-on-section.patch
"
builddir="$srcdir/$_repository-$_commit"
_outdir="out"

# Strictily use GCC6
# This kernel hasn't been tested with other compilers than GCC6
if [ "${CC:0:5}" != "gcc6-" ]; then
	CC="gcc6-$CC"
	HOSTCC="gcc6-gcc"
	CROSS_COMPILE="gcc6-$CROSS_COMPILE"
fi


prepare() {
	default_prepare
	. downstreamkernel_prepare
}

build() {
	unset LDFLAGS
	make O="$_outdir" ARCH="$_carch" CC="${CC:-gcc}" \
		KBUILD_BUILD_VERSION="$((pkgrel + 1 ))-postmarketOS"
}

package() {
	downstreamkernel_package "$builddir" "$pkgdir" "$_carch" \
		"$_flavor" "$_outdir"
}

sha512sums="
06ac698b5689c823e985b27895c39cb9bc5e2a5af27d4910bc5bb95d90d71a7c8cfa55856d070404b69683d35d8c1011ea7a0eb4b47678b5ec585129d258529d  linux-samsung-loganrelte-0a35d79cc544b24168450e46216dd649c7fd339b.tar.gz
b04dfffd8b8903415c4ed32fb12d562defde6e5c94bd3e2a6ab808344f2fff28066de9631222f8869eeaa438867c0f3630c148066ef5c8b97fc70997213615be  config-samsung-loganrelte.armv7
f85ced49ee2f2461adea68dac0a10452aa809a7d41d869092d94eb085344919a9a385dec0c48011f4601ca4f441700f7fe49075c7eca4fb2d66b01f7d413ccb7  01_msm-fix-perf_trace_counters.patch
7be03a9e78b7ac330a54b1f00509caa0621a95c0c55901878ad757f9dd69cc05ba2c8b5ea987063ae1224f92c4d090d515fa5d369e7755181a4871b0d0f82881  02_gpu-msm-fix-gcc5-compile.patch
e3083c260ed9c4fc0d83f43106700b6173876dbfae072f6e6696ac6785a4dc17771fbcb3e21601e04ed29a11bf0f7a2a09ad549375e0c34cea245c7f2e2bcbbd  03_fix-video-argb-setting.patch
9e3b067fa1b19ad02500c4fce1b6142051df3845c508e615788beb650c4f953683107ac2d80670c4e3df38f532e0e91060d2d13ec04c9ec985abd2dfa82e900b  linux3.4-ARM-8933-1-replace-Sun-Solaris-style-flag-on-section.patch
"
